var express = require('express');
var router = express.Router();

const {
  addProducts,
  getProducts,
  deleteProducts
} = require('../service/productsService.js');

//获取保险产品信息 渲染列表
router.get('/getProducts', async function (req, res, next) {
  const data = await getProducts(req.query);
  // console.log(111, data);
  res.send(data);
})
//新增保险产品
router.post("/addProducts", async (req, res, next) => {
  const data = await addProducts(req.body);
  // console.log(111,req.body);
  console.log(111, data);
  res.send(data);
});

//删除数据
router.post('/deleteProducts', async (req, res, next) => {
  const { _id } = req.body;
  // console.log(111,_id);
  const data = await deleteProducts({ _id });
  res.send(data);
})

module.exports = router;
